package com.edu.web.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.edu.dao.impl.ShiDaoImpl;
import com.edu.entity.Shi;
import com.edu.entity.ShiCs;
import com.edu.service.impl.GreenUserSericeImpl;
import com.edu.service.impl.UserServiceImpl;

/**
 * Servlet implementation class InserShiServlet
 */
@WebServlet("/InserShiServlet")
public class InserShiServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
   
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	/**
	 *
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		UserServiceImpl userServletImpl=new UserServiceImpl();
		GreenUserSericeImpl greenUserSericeImpl =new GreenUserSericeImpl();
		Shi user=new Shi();
		ShiCs u =new ShiCs();
		user.setAuthor(request.getParameter("spassword"));
		user.setTitle(request.getParameter("socp"));
		
		u.setNewNventContent(request.getParameter("snameuser"));
		u.setCost(request.getParameter("b"));
		u.setEmail(request.getParameter("a"));
		u.setEventCategory(request.getParameter("d"));
		u.setOrganizer(request.getParameter("one"));
		u.setPhone(request.getParameter("c"));
		u.setPlace(request.getParameter("to"));
		userServletImpl.InsertShi(user);
		userServletImpl.InsertShics(u);
		ShiDaoImpl Reasones =new ShiDaoImpl();
		request.setAttribute("Reasons", Reasones.alls());
		request.getRequestDispatcher("manage-Shi.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
